package com.stone.persistent.recyclerview.extensions;

import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.fragment.app.FragmentActivity;

import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Field;


public class ActivityExtensions {


    public  static void immerseStatusBar(FragmentActivity immerseStatusBar) {
        if (Build.VERSION.SDK_INT >= 21) {
            Window window = immerseStatusBar.getWindow();
            window.setStatusBarColor(0);
            window = immerseStatusBar.getWindow();
            View var1 = window.getDecorView();
            var1.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        } else {
            immerseStatusBar.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }

    }

    public static  int getStatusBarHeight(@NotNull FragmentActivity getStatusBarHeight) {
        int statusBarHeight = 0;

        try {
            Class clz = Class.forName("com.android.internal.R$dimen");
            Object obj = clz.newInstance();
            Field field = clz.getField("status_bar_height");
            int status_bar_height = Integer.parseInt(field.get(obj).toString());
            statusBarHeight = getStatusBarHeight.getResources().getDimensionPixelSize(status_bar_height);
        } catch (Exception var6) {
            var6.printStackTrace();
        }

        return statusBarHeight;
    }

    public static  int getScreenWidth(@NotNull FragmentActivity getScreenWidth) {
        DisplayMetrics dm = new DisplayMetrics();
        WindowManager var10000 = getScreenWidth.getWindowManager();
        var10000.getDefaultDisplay().getMetrics(dm);
        return dm.widthPixels;
    }
}
